1. Field of the Invention
The present invention relates to a three-dimensional image processing apparatus, a three-dimensional image processing method, a three-dimensional image processing program, a computer-readable recording medium, and a recording device.
2. Description of Related Art
In a large number of production sites such as factories, there have been introduced image processing apparatuses that realize automatic and fast performance of inspections, which have relied on viewing of humans. The image processing apparatus captures an image of a workpiece that comes flowing through a production line such as a belt conveyor by use of a camera, and executes measurement processing such as edge detection and area calculation for a predetermined region by use of the obtained image data. Then, based on a processing result of the measurement processing, the apparatus performs inspections such as detection of a crack on the workpiece and positional detection of alignment marks, and outputs determination signals for determining the presence or absence of a crack on the workpiece and positional displacement. In such a manner, the image processing apparatus may be used as one of FA (Factory Automation) sensors.
An image which is taken as a measurement processing target by the image processing apparatus that is used as the FA sensor is principally a brightness image not including height information. For this reason, speaking of the foregoing detection of a crack on the workpiece, the apparatus is good at stably detecting a two-dimensional shape of a cracked portion, but having difficulties in stably detecting a three-dimensional shape of, for example, a depression of a flaw which is not apt to appear in a brightness image. For example, it is thought that a type or a direction of illumination that illuminates the workpiece during the inspection is devised and a shade caused by a depression of a flaw is detected to indirectly detect a three-dimensional shape, but a clear shade is not necessarily always detected in the brightness image. In order to prevent an erroneous determination which is to erroneously detect a defective product as a non-defective product at the time of an unclear shade being detected, for example, if a determination threshold is biased to the safe side, the apparatus might determine a large number of non-defective products as defective products, to cause deterioration in production yield.
Accordingly, there is considered a visual inspection which uses not only a brightness image that takes, as a pixel value, a shade value in accordance with a light reception amount of the camera but also a distance image that takes, as a pixel value, a shade value in accordance with a distance from the camera to the workpiece to two-dimensionally express a height (e.g. see Unexamined Japanese Patent Publication No. 2012-21909).
An example of the three-dimensional image processing apparatus is shown in a schematic view of FIG. 160. This three-dimensional image processing apparatus is configured of a head section provided with an image capturing part such as a light reception element, and a controller section which is connected to the head section and is sent image data captured in the head section, to generate a distance image from the acquired image data.
Here, the principle of triangulation will be described based on FIG. 160. In the head section, an angle α between an optical axis of incident light emitted from a light projecting section 110 and an optical axis of reflected light that is incident on a light receiving section 120 (optical axis of the light receiving section 120) is previously set. Here, when the workpiece is not mounted on a workpiece mounting place, incident light emitted from the light projecting section 110 is reflected by a point O on the workpiece mounting surface and is incident on the light receiving section 120. On the other hand, when the workpiece is mounted on the workpiece mounting place, the incident light emitted from the light projecting section 110 is reflected by a point A on the surface of the workpiece and is incident as reflected light on the light receiving section 120. Then, a distance d in an X-direction between the point O and the point A is measured, and based on this distance d, a height h of the point A on the surface of the workpiece is calculated.
Heights of all points on the surface of the workpiece are calculated applying the foregoing the measurement principle of triangulation, thereby to measure a three-dimensional shape of the workpiece. In a pattern projecting method, in order that all the points on the surface of the workpiece are irradiated with incident light, the incident light is emitted from the light projecting section 110 in accordance with a predetermined structured pattern, reflected light as the light reflected on the surface of the workpiece is received, and based on a plurality of received pattern images, the three-dimensional shape of the workpiece is efficiently measured.
As such a pattern projecting method, there are known a phase shift method, a spatial coding method, a multi-slit method and the like. By the three-dimensional measurement processing performed using the pattern projecting method, a projection pattern is changed to repeat image-capturing a plurality of times in the head section, and the images are transmitted to the controller section. In the controller section, computing is performed based on the pattern projected images transmitted from the head section, and a distance image having height information of the workpiece can be obtained.
On the other hand, in the existing image processing apparatus, there is principally used a brightness image that takes brightness as a pixel value. For example, there exists a system for capturing a shade image of a workpiece being conveyed on a production line by use of a monochromatic camera, to perform an inspection by image processing. In such circumstances, when a new three-dimensional measurement apparatus and a processing apparatus for performing processing on three-dimensional data (point cloud data) outputted from the measurement apparatus are intended to be introduced, it takes considerable cost.
Accordingly, when height information is expressed as a distance image that expresses it as a shade of an image, image data to be handled is itself equivalent to the existing brightness image, and hence the distance image can be handled in equipment of the image processing apparatus using the existing brightness image.
In this case, as for the conventional brightness image, an image with relatively a low number of tones has been used. For example, there have been often used images each expressing information per pixel by 8 tones. On the other hand, as for image data having height information, a large number of tones (e.g., 16 tones) are necessary for expressing the height information. For this reason, in order to allow the distance image to be processed by the image processing apparatus that handles the existing low-tone image, it is necessary to convert a multi-tone distance image to a relatively low-tone distance image. (Hereinafter, the image obtained by converting a multi-tone distance image to a relatively low-tone distance image is referred to as “low-tone distance image”, and the conventional shade image having brightness information is referred to as “brightness image”.)
As thus described, by using the tone-converted low-tone distance image on top of the conventionally used brightness image, not only image processing such as the conventional shape extraction but also processing such as height measurement performed using height information can be used in the three-dimensional image processing apparatus at the time of inspection for determining the normality or abnormality of the workpiece.
However, at the time of performing the tone conversion processing on a high-tone distance image into a low-tone distance image so as to be used in the existing three-dimensional image processing apparatus, when a distance image is simply converted to a low-tone distance image, the number of tones is lowered to reduce a dynamic range. As a result, height information is lost to cause deterioration in accuracy, and the necessary inspection accuracy cannot be obtained, which has been problematic. There have been cases where an image appropriate for an inspection cannot be obtained depending on a condition of the workpiece especially when the high-tone distance image is tone-converted with a fixed tone conversion parameter.